package com.lzx.reggie.entity

import com.baomidou.mybatisplus.annotation.FieldFill
import com.baomidou.mybatisplus.annotation.TableField
import java.io.Serializable
import java.math.BigDecimal
import java.time.LocalDateTime


open class Dish(
    var id: Long? = null,
    //菜品名称
    var name: String? = null,
    //菜品分类id
    var categoryId: Long? = null,
    //菜品价格
    var price: BigDecimal? = null,
    //商品码
    var code: String? = null,
    //图片
    var image: String? = null,
    //描述信息
    var description: String? = null,
    //0 停售 1 起售
    var status: Int? = null,
    //顺序
    var sort: Int? = null,

    @TableField(fill = FieldFill.INSERT)
    var createTime: LocalDateTime? = null,

    @TableField(fill = FieldFill.INSERT_UPDATE)
    var updateTime: LocalDateTime? = null,

    @TableField(fill = FieldFill.INSERT)
    var createUser: Long? = null,

    @TableField(fill = FieldFill.INSERT_UPDATE)
    var updateUser: Long? = null
) : Serializable {

    companion object {
        private const val serialVersionUID = 1L
    }

    override fun equals(other: Any?): Boolean {
        if (this === other) return true
        if (other !is Dish) return false

        if (id != other.id) return false
        if (name != other.name) return false
        if (categoryId != other.categoryId) return false
        if (price != other.price) return false
        if (code != other.code) return false
        if (image != other.image) return false
        if (description != other.description) return false
        if (status != other.status) return false
        if (sort != other.sort) return false
        if (createTime != other.createTime) return false
        if (updateTime != other.updateTime) return false
        if (createUser != other.createUser) return false
        if (updateUser != other.updateUser) return false

        return true
    }

    override fun hashCode(): Int {
        var result = id?.hashCode() ?: 0
        result = 31 * result + (name?.hashCode() ?: 0)
        result = 31 * result + (categoryId?.hashCode() ?: 0)
        result = 31 * result + (price?.hashCode() ?: 0)
        result = 31 * result + (code?.hashCode() ?: 0)
        result = 31 * result + (image?.hashCode() ?: 0)
        result = 31 * result + (description?.hashCode() ?: 0)
        result = 31 * result + (status ?: 0)
        result = 31 * result + (sort ?: 0)
        result = 31 * result + (createTime?.hashCode() ?: 0)
        result = 31 * result + (updateTime?.hashCode() ?: 0)
        result = 31 * result + (createUser?.hashCode() ?: 0)
        result = 31 * result + (updateUser?.hashCode() ?: 0)
        return result
    }

    override fun toString(): String {
        return "Dish(id=$id, name=$name, categoryId=$categoryId, price=$price, code=$code, image=$image, description=$description, status=$status, sort=$sort, createTime=$createTime, updateTime=$updateTime, createUser=$createUser, updateUser=$updateUser)"
    }

}
